package com.example.rain.bindservice;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {

    class MyBinder extends Binder{
        public int callMethodInService(String str){
            return methodInService(str);

        }

        public void callMyMethodInService(){
            myMethod();
        }
    }

    @Override
    public void onCreate() {
        Log.i("MyService","创建服务，调用onCreate()");
        super.onCreate();
    }
    @Override
    public IBinder onBind(Intent intent) {
        Log.i("MyService","绑定服务，调用onBind()");
        return new MyBinder();
    }

    private int methodInService(String str) {
        Log.i("MyService","自定义方法methodInService(): "+str);
        return 1;
    }

    private void myMethod(){
        Log.i("MyService","自定义方法myMethod()");
    }

    public MyService() {
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.i("MyService","解绑服务，调用onUnbind()");
        return super.onUnbind(intent);
    }


}
